

export const gmAdapter = (config: any) => {

  // console.log("__XUANXIAOQIAN__gmAdapter", config.url)

  return new Promise((resolve, reject) => {
    GM_xmlhttpRequest({
      method: config.method.toUpperCase(),
      url: config.url,
      headers: config.headers,
      data: config.data,
      responseType: config.responseType,
      timeout: config.timeout || 10000, // 直接使用axios的timeout配置
      onload: (response) => {
        resolve({
          data: response.response,
          status: response.status,
          statusText: response.statusText,
          headers: response.responseHeaders,
          config: config,
          request: response
        })
      },
      onerror: (error) => {
        reject(error)
      },
      ontimeout: () => {
        reject(new Error('Request timeout'))
      }
    })
  })
}
